package com.torches.cloud.entities;

import java.util.HashMap;
import java.util.List;

public class FileEntity {

    private String fileName;
    private String filePath;
    private String fileType;
    private String lastModified;
    private boolean isFolder;
    private long fileSize;


    public FileEntity() {

    }

    public FileEntity(String fileName, String filePath, String lastModified, boolean isFolder, long fileSize) {
        this.fileName = fileName;
        this.fileType = FileEntity.getFileType(fileName,isFolder);
        this.filePath = filePath;
        this.lastModified = lastModified;
        this.isFolder = isFolder;
        this.fileSize = fileSize;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public boolean isFolder() {
        return isFolder;
    }

    public void setFolder(boolean folder) {
        isFolder = folder;
    }

    public long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Integer fileSize) {
        this.fileSize = fileSize;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    public String getLastModified() {
        return lastModified;
    }

    public void setLastModified(String lastModified) {
        this.lastModified = lastModified;
    }

    public static String getFileType(String fileName,boolean isFolder){
        if (isFolder){
            return "folder";
        }
        String fileType = fileName.substring(fileName.lastIndexOf('.') + 1);

        return fileType;
    }

    public static String getFileNameFormUrl(String filePath){
        return filePath.substring(filePath.lastIndexOf("/")+1);
    }

    @Override
    public String toString() {
        return "FileEntity{" +
                "fileName='" + fileName + '\'' +
                ", filePath='" + filePath + '\'' +
                ", fileType='" + fileType + '\'' +
                ", lastModified='" + lastModified + '\'' +
                ", isFolder=" + isFolder +
                ", fileSize=" + fileSize +
                '}';
    }


}
